
package DataModel.SegmentTree;

import java.util.ArrayList;


/**
 * Implementation of Segment Tree Node Interface
 * @author Guy
 *
 */
public class SegmentTreeNodeImpl implements SegmentTreeNode {

	private long begining =0;
	
	private long end = 0;
		
	private SegmentTreeNodeImpl  leftSon = null;
	
	private SegmentTreeNodeImpl  rightSon = null;

	private ArrayList<Long> data = null;
	
	private SegmentTreeNodeGenData genericData = null; 
	
	/**
	 * Constructor of the node- gets begining and end of interval
	 * @param begining
	 * @param end
	 */
	public SegmentTreeNodeImpl(long begining, long end ) {
		this.begining = begining;
		this.end = end;
		data = new ArrayList<Long>();
	}
	public void setGenericData( SegmentTreeNodeGenData genericData) {
		this.genericData = genericData;
	}
	public long getBegining() {
		return this.begining;
		
	}

	public long getEnd() {
		return this.end;
	}

	public SegmentTreeNode leftSon() {
		
		return this.leftSon;
	}
	
	public SegmentTreeNode rightSon() {
		return this.rightSon;
	}

	public void insertData(long segementId) {
		data.add(segementId);
	}

	public void removeData(long segmentId) {
		data.remove(segmentId);
	}


	public ArrayList getData() {
		return this.data;
	}

	public void setLeftSon(SegmentTreeNode leftSon) {
		this.leftSon = (SegmentTreeNodeImpl) leftSon;
	}

	public void setRightSon(SegmentTreeNode rightSon) {
		this.rightSon = (SegmentTreeNodeImpl) rightSon;
	}

	public int getNumEdges() {
		return this.data.size();
	}
	public SegmentTreeNodeGenData getGenericData() {
		return this.genericData;
	}
	
	
	

}
